package com.unitd.scheduler.test;

import com.unitd.frame.spring.SpringInstanceFactory;
import com.unitd.frame.spring.SpringInstanceProvider;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

import java.util.Scanner;

/**
 * @desc 测试定时任务分布式部署时,任务执行情况
 * @filename JobInterceptor.java
 * @copyright www.unitd.com
 * @author Hudan
 * @version 1.0
 * @date 2016/10/14
 */
public class TaskServerNode1 {

	private static Logger logger = LoggerFactory.getLogger(TaskServerNode1.class);

	public static void main(String[] args) {

		final ClassPathXmlApplicationContext context = new ClassPathXmlApplicationContext("META-INF/spring/spring-*.xml");

		SpringInstanceFactory.setSpringInstanceProvider(new SpringInstanceProvider(context));

		logger.info("TASK started....");
		Runtime.getRuntime().addShutdownHook(new Thread(new Runnable() {

			@Override
			public void run() {
				logger.info("TASK Stoped....");
				context.close();
			}
		}));

		Scanner scan = new Scanner(System.in);
		String cmd = scan.next();
		if ("q".equals(cmd)) {
			scan.close();
			context.close();
		}
	}
}